from django.core.management.base import BaseCommand
from ...utils.crawler import News

class Command(BaseCommand):
    help = 'Run the news crawler'

    def handle(self, *args, **kwargs):
        news_crawler = News(url='https://news.buaa.edu.cn/zhxw.htm', path='./data')
        news_crawler.getNews(earliest='2020-01-01')
        news_crawler.genWordCloud()
        self.stdout.write(self.style.SUCCESS('Successfully ran the crawler'))